//
//  LspNbNavViewController.swift
//  LspSwiftFinayTest
//
//  Created by lsp's mac pro on 2018/3/27.
//  Copyright © 2018年 lsp's mac pro. All rights reserved.
//

import UIKit

class LspNbNavViewController: UINavigationController {
    
    override func viewDidLoad() {
        navigationBar.isHidden=true
    }
    
/// 这里是为了封装一个方法，封装的是在push 的时候隐藏tabbar 
  override  func pushViewController(_ viewController: UIViewController, animated: Bool) {
    if childViewControllers.count>0 {
       viewController.hidesBottomBarWhenPushed=true
        if let vc=viewController as? LspNbBaseViewController{
            var  title = "返回"
            
            if childViewControllers.count==1{
                
                title=childViewControllers.first?.title ?? "返回"
            }
            vc.navItem.leftBarButtonItem=UIBarButtonItem(title: "返回", target: self, action: #selector(popToParent),isBack:true)
            
        }
    }
   
    super.pushViewController(viewController, animated: true)
    
    }
    
    @objc private func popToParent() {
        popViewController(animated: true)
    }
}
